﻿using Company.Application.Share.Config;
using Company.Core.Attributes;
using Company.Hardware.Camera;
using Company.Hardware.Detector;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Company.Application.Setting.Services
{
    /// <summary>
    /// 系统配置管理器（统一管理多个配置）
    /// </summary>
    [ExposedService(Lifetime.Singleton, typeof(ISettingProvider), typeof(ISoftwareSettingProvider), typeof(ICameraConfigProvider), typeof(IDetectorConfigProvider))]
    public class SettingProvider : ISettingProvider, ISoftwareSettingProvider, ICameraConfigProvider, IDetectorConfigProvider
    {
        public SettingProvider(SettingManager settingManager)
        {
            SoftwareSetting = settingManager.Config.SoftwareSetting;
            CameraConfig = settingManager.Config.CameraConfig;
            DetectorConfig = settingManager.Config.DetectorConfig;
        }
        public SoftwareSetting SoftwareSetting { get; }

        public CameraConfig CameraConfig { get; }

        public DetectorConfig DetectorConfig { get; }

        public event Action OnChanged;

        public void Invoke()
        {
            OnChanged?.Invoke();
        }
    }
}
